package LoginPackage;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeMethod;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import PagePackage.MyPageFactory;
import PagePackage.internalPageClass;
import PagePackage.loginPageClass;
import PagePackage.newSchoolPage;
import PagePackage.leaguePage;
import PagePackage.addLeaguePage;
import PagePackage.newTeamPage;
import PagePackage.userContactInfoPageClass;

public class TestBaseClass {
	protected WebDriver driver;	
	protected String baseUrl;
	protected loginPageClass loginPage;
	protected internalPageClass internalPage;
	protected leaguePage leaguePage;
	protected addLeaguePage addleaguePage;
	protected  WebDriverWait wait;
	protected newSchoolPage newSchoolPage;
	protected newTeamPage newTeam;
	protected userContactInfoPageClass contactInfo;
	protected String adminEmail;
	protected String adminPassword;
	protected String coachEmail;
	protected String editEmail;
	protected String saEmail;
	protected String saPassword;
	protected String assistantCoachEmail;
	protected String athleteRole;
	protected String adminEditsUserfirstName;
	protected String adminEditsUserlastName;
	protected String adminEditsUseremail;
	protected String adminEditsUserphone1;
	protected String adminEditsUserphone2;
	protected String saEditsUserfirstName;
	protected String saEditsUserlastName;
	protected String saEditsUseremail;
	protected String saEditsUserphone1;
	protected String saEditsUserphone2;
	protected String basketballSport;
	public String adminCreatesNewCoachfirstName;
	protected String adminCreatesNewCoachlastName;
	protected String adminCreatesNewCoachphone1;
	protected String adminCreatesNewCoachphone2;
	protected String headCoachrole;
	protected String universityTeam;
	protected String cancelUserCreationemail;
	protected String cancelUserCreationphone1;
	protected String cancelUserCreationphone2;
	protected String asCoachrole;
	protected String adminCreatesAsCoachfirstName;
	protected String adminCreatesAsCoachlastName;
	protected String adminCreatesAsCoachphone1;
	protected String adminCreatesAsCoachphone2;
	protected String footballSport;
	protected String highschoolteam;
	protected String adminCreatesIndexerfirstName;
	protected String adminCreatesIndexerlastName;
	protected String adminCreatesIndexerphone1;
	protected String adminCreatesIndexerphone2;
	protected String indexerRole;
	protected String indexerEmail;
	protected String adminCreatesAthletefirstName; 
	protected String adminCreatesAthletelastName;
	protected String adminCreatesAthletephone1;
	protected String adminCreatesAthletephone2;
	protected String athleteEmail;
	protected String athleterole;
	protected String adminRemovesRolesfirstName;
	protected String adminRemovesRoleslastName; 
	protected String adminRemovesRolesemail;
	protected String adminRemovesRolesphone1;
	protected String adminRemovesRolesphone2;
	protected String lacrosseSport;
	protected String otherTeam;
	protected String saCreatesNewCoachemail;
	protected String saCancelsNewUserCreationemail;
	protected String saCreatesAssistantCoachemail;
	protected String saCreatesIndexeremail;
	protected String saCreatesAthleteemail;
	protected String saRemovesRolesemail;
	protected String userrole;
	protected String saEditEmail;
	protected String lockedUser;
	protected String lockedUserPassword;
	protected String SAlockedUser;
	protected String SAlockedUserPassword;
	protected String lockedAdmin;
	protected String SAlockedAdmin;
	protected String lockedAdminPassword;
	protected String SAlockedAdminPassword;
	protected String lockedSA;
	protected String lockedSAPassword;
	@BeforeMethod
	public void setUp() throws Exception{
		driver = WebDriverFactory.getDriver(DesiredCapabilities.firefox());
	    baseUrl = "https://www-dev.krossover.com/intelligence-qa/login";
	    driver.manage().timeouts().implicitlyWait(7, TimeUnit.SECONDS);
		wait = new WebDriverWait (driver, 10); 	
		loginPage = PageFactory.initElements(driver, loginPageClass.class);
		internalPage = PageFactory.initElements(driver, internalPageClass.class);
		newSchoolPage = PageFactory.initElements(driver, newSchoolPage.class);
		leaguePage = PageFactory.initElements(driver, leaguePage.class);
		addleaguePage = PageFactory.initElements(driver, addLeaguePage.class);
		newTeam = PageFactory.initElements(driver, newTeamPage.class);
		contactInfo = PageFactory.initElements(driver, userContactInfoPageClass.class);
		adminEmail = getDataProperties("admin.email");
		adminPassword = getDataProperties("admin.password");
		coachEmail = getDataProperties("headCoach.email");
		saEmail = getDataProperties("sa.email");
		saPassword = getDataProperties("sa.password");
		assistantCoachEmail = getDataProperties("assistantCoach.email");
		athleteRole = getDataProperties("athleteRole");
		adminEditsUserfirstName = getDataProperties ("adminEditsUser.firstName");
		adminEditsUserlastName =  getDataProperties ("adminEditsUser.lastName");
		adminEditsUseremail = getDataProperties ("adminEditsUser.email");
		adminEditsUserphone1 = getDataProperties ("adminEditsUser.phone1");
		adminEditsUserphone2 = getDataProperties ("adminEditsUser.phone2");
		saEditsUserfirstName = getDataProperties ("SAEditsUser.firstName");
		saEditsUserlastName = getDataProperties ("SAEditsUser.lastName");
		saEditsUseremail = getDataProperties ("SAEditsUser.email2");
		saEditsUserphone1 = getDataProperties ("SAEditsUser.phone1");
	    saEditsUserphone2 = getDataProperties ("SAEditsUser.phone2");
	    adminCreatesNewCoachfirstName = getDataProperties ("adminCreatesNewCoach.firstName");
		adminCreatesNewCoachlastName = getDataProperties ("adminCreatesNewCoach.lastName");
		adminCreatesNewCoachphone1 = getDataProperties ("adminCreatesNewCoach.phone1");
		adminCreatesNewCoachphone2 = getDataProperties ("adminCreatesNewCoach.phone2");
		headCoachrole = getDataProperties("headCoach.role");
		basketballSport = getDataProperties("basketball.sport");
	    universityTeam = getDataProperties("university.team");
	    cancelUserCreationemail = getDataProperties("cancelUserCreation.email");
	    cancelUserCreationphone1 = getDataProperties("cancelUserCreation.phone1");
	    cancelUserCreationphone2 = getDataProperties("cancelUserCreation.phone2");
	    asCoachrole = getDataProperties("asCoach.role");
	    adminCreatesAsCoachfirstName = getDataProperties("adminCreatesAsCoach.firstName");
		adminCreatesAsCoachlastName = getDataProperties("adminCreatesAsCoach.lastName");
		adminCreatesAsCoachphone1 = getDataProperties("adminCreatesAsCoach.phone1");
		adminCreatesAsCoachphone2 = getDataProperties("adminCreatesAsCoach.phone2");
		footballSport=getDataProperties("football.sport");
		highschoolteam = getDataProperties ("highschool.team");
		adminCreatesIndexerfirstName = getDataProperties ("adminCreatesIndexer.firstName");
		adminCreatesIndexerlastName  = getDataProperties ("adminCreatesIndexer.lastName");
		adminCreatesIndexerphone1  = getDataProperties ("adminCreatesIndexer.phone1");
		adminCreatesIndexerphone2 = getDataProperties ("adminCreatesIndexer.phone2");
		indexerRole = getDataProperties ("indexer.role");
		indexerEmail = getDataProperties ("indexer.email");
		adminCreatesAthletefirstName = getDataProperties ("adminCreatesAthlete.firstName");
	    adminCreatesAthletelastName = getDataProperties ("adminCreatesAthlete.lastName");
		adminCreatesAthletephone1 = getDataProperties ("adminCreatesAthlete.phone1");
		adminCreatesAthletephone2 = getDataProperties ("adminCreatesAthlete.phone2");
		athleteEmail = getDataProperties ("athlete.email");
		athleterole = getDataProperties ("athlete.role");
		adminRemovesRolesfirstName = getDataProperties ("adminRemovesRoles.firstName");
		adminRemovesRoleslastName = getDataProperties ("adminRemovesRoles.lastName ");
		adminRemovesRolesemail = getDataProperties ("adminRemovesRoles.email");
		adminRemovesRolesphone1 = getDataProperties ("adminRemovesRoles.phone1");
		adminRemovesRolesphone2 = getDataProperties ("adminRemovesRoles.phone2");
		lacrosseSport = getDataProperties ("lacrosse.sport");
		otherTeam = getDataProperties ("other.team");
		saCreatesNewCoachemail = getDataProperties("saCreatesNewCoach.email ");
		saCancelsNewUserCreationemail = getDataProperties("saCancelsNewUserCreation.email");
		saCreatesAssistantCoachemail = getDataProperties("saCreatesAssistantCoach.email");
		saCreatesIndexeremail = getDataProperties("saCreatesIndexer.email");
		saCreatesAthleteemail = getDataProperties("saCreatesAthlete.email");
		saRemovesRolesemail = getDataProperties("saRemovesRoles.email");
		editEmail=getDataProperties("editUser.email");
		saEditEmail= getDataProperties("SAeditsUser.email");
		lockedUser=getDataProperties("adminUnlockedUser.lockedUser");
		lockedUserPassword=getDataProperties("adminUnlockedUser.lockedUserPassword");
		SAlockedUser=getDataProperties("saUnlockedUser.SAlockedUser");
		SAlockedUserPassword=getDataProperties("PasswordsaUnlockedUser.SAlockedUserPassword");
		lockedAdmin = getDataProperties("AdminUnlocksAdmin.lockedAdmin");
		SAlockedAdmin = getDataProperties("SAUnlocksAdmin.SAlockedAdmin");
		lockedAdminPassword = getDataProperties("AdminUnlocksAdmin.lockedAdminPassword");
		SAlockedAdminPassword = getDataProperties("SAUnlocksAdmin.SAlockedAdminPassword");
		lockedSA = getDataProperties("AdminUnlocksSA.lockedSA");
	    lockedSAPassword = getDataProperties("AdminUnlocksSA.lockedSAPassword");
				
		
		
		
		
		
	}
	public loginPageClass goToMainPage() {
		driver.get(baseUrl); 
		driver.manage().window().maximize(); 
		return MyPageFactory.getPage(driver, loginPageClass.class);
	}
	
	public static String getDataProperties (String param) throws Exception {
		Properties props=new Properties();
		props.load(new InputStreamReader(new FileInputStream("system.properties")));
		return props.getProperty(param);
		}
}
